/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.app.controller;

import com.app.entity.Ingrediente;
import com.app.sessionBeans.IngredienteFacade;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.view.ViewScoped;
import javax.inject.Named;
import org.primefaces.event.FlowEvent;

/**
 *
 * @author EduardoAlexis
 */
@Named(value = "ingredienteController")
@ViewScoped
public class IngredienteController {
@EJB
private IngredienteFacade ingredienteFacade;
private Ingrediente selected = new Ingrediente();
private List<Ingrediente> items=null;    
private boolean skip;
    
    public IngredienteController() {
    }

    //--- wizard    
    public boolean isSkip() {
        return skip;
    }
 
     
    public void setSkip(boolean skip) {
        this.skip = skip;
    }
    
    
     public String onFlowProcess(FlowEvent event) {
        if(skip) {
            skip = false;   //reset in case user goes back
            return "confirm";
        }
        else {
            return event.getNewStep();
           
        }
    }
    
    
    public IngredienteFacade getIngredienteFacade() {
        return ingredienteFacade;
    }

    public Ingrediente getSelected() {
        return selected;
    }

    public void setSelected(Ingrediente selected) {
        this.selected = selected;
    }

    public List<Ingrediente> getItems() {
        if (items==null){
        items=getIngredienteFacade().findAll();
        }
        return items;
    }

    public void setItems(List<Ingrediente> items) {
        this.items = items;
    }
    
    public String prepareToCreate(){
   
    return "nuevoIngrediente";
    }
    
    
    
    
    
}
